package com.popupwindowdemo;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;

import list.ListMainActivity;

public class MainActivity extends AppCompatActivity {

    private PopupWindowNumber mPopupWindowNumber;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button BtnPopupWindow = (Button) findViewById(R.id.btn_popupwindow);
        BtnPopupWindow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //正常点击的逻辑
                mPopupWindowNumber = new PopupWindowNumber(MainActivity.this);
                mPopupWindowNumber.showAtLocation(MainActivity.this.findViewById(R.id.main), Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0);
            }
        });

        Button BtnSubjectKind = (Button) findViewById(R.id.btn_subject_kind);
        BtnSubjectKind.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getApplicationContext(), SubjectKindActivity.class));
            }
        });

        Button BtnZSD = (Button) findViewById(R.id.btn_zsd);
        BtnZSD.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getApplicationContext(), ZsdActivity.class));
            }
        });

        Button BtnDialog = (Button) findViewById(R.id.btn_dialog);
        BtnDialog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                submitDialog();
            }
        });

        Button BtnList = (Button) findViewById(R.id.btn_list);
        BtnList.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getApplicationContext(), ListMainActivity.class));
            }
        });

    }


    public void submitDialog() {
        final DialogWrong mDialogWrong = new DialogWrong(this);
        mDialogWrong.getWindow().setWindowAnimations(R.style.CustomDialog);
        mDialogWrong.show();
        mDialogWrong.setClicklistener(new DialogWrong.ClickListenerInterface() {

            @Override
            public void doSee() {
                mDialogWrong.dismiss();
            }

            @Override
            public void doNext() {
                mDialogWrong.dismiss();
            }

            @Override
            public void doBack() {
                mDialogWrong.dismiss();
            }

        });
    }

}
